Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exec: do not leak session IDs on errors #20394

Merged
merged 2 commits into from
Oct 18, 2023

Conversation

giuseppe
Copy link
Member

always cleanup the exec session when the command specified to the "exec" is not found.

Closes: #20392

Does this PR introduce a user-facing change?

exec sessions are not leaked when the specified command does not exist

@openshift-ci openshift-ci bot added release-note approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 18, 2023
@@ -759,11 +759,21 @@ func (c *Container) Exec(config *ExecConfig, streams *define.AttachStreams, resi
// Exec emulates the old Libpod exec API, providing a single call to create,
// run, and remove an exec session. Returns exit code and error. Exit code is
// not guaranteed to be set sanely if error is not nil.
func (c *Container) exec(config *ExecConfig, streams *define.AttachStreams, resizeChan <-chan resize.TerminalSize, isHealthcheck bool) (int, error) {
func (c *Container) exec(config *ExecConfig, streams *define.AttachStreams, resizeChan <-chan resize.TerminalSize, isHealthcheck bool) (ExitCode int, Err error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit local vars should IMO always start lower case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linter agrees with you

test/system/075-exec.bats Outdated Show resolved Hide resolved
@giuseppe giuseppe force-pushed the cleanup-exec-session-on-errors branch from 2105e26 to 266b0d3 Compare October 18, 2023 09:07
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 18, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe, vrothberg

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@giuseppe giuseppe force-pushed the cleanup-exec-session-on-errors branch from 266b0d3 to 9b99b8d Compare October 18, 2023 09:28
@giuseppe giuseppe force-pushed the cleanup-exec-session-on-errors branch from 9b99b8d to bb8abdc Compare October 18, 2023 10:24
libpod/container_exec.go Outdated Show resolved Hide resolved
always cleanup the exec session when the command specified to the
"exec" is not found.

Closes: containers#20392

Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe giuseppe force-pushed the cleanup-exec-session-on-errors branch from bb8abdc to fa19e1b Compare October 18, 2023 13:02
@rhatdan
Copy link
Member

rhatdan commented Oct 18, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 18, 2023
@openshift-ci openshift-ci bot merged commit aabe5c8 into containers:main Oct 18, 2023
51 of 98 checks passed
@edsantiago
Copy link
Member

This has broken CI. All remote system tests are now failing on (what looks like) all PRs. @giuseppe please treat this as urgent.

@giuseppe
Copy link
Member Author

not even sure how to fix it properly. @mheon should we add a new function to the bindings to allow ExecRemove from the remote client? I don't think the cleanup should be done automatically server-side on failures

@edsantiago
Copy link
Member

I'm really confused: how did this pass CI? It's failing hard, solid not-flaking 100%, on every other in-flight PR that I see.

@giuseppe
Copy link
Member Author

ideally, a merge should be possible only when the CI is all green (or has a way to explicitly force it if needed). A /lgtm alone should not bypass the CI causing these emergencies

@edsantiago
Copy link
Member

Oh! That's it, I see now. It merged while CI was still running. I hadn't seen that.

Yes, "ideally". Nobody anywhere in the universe will disagree with you. Unfortunately this is not an ideal world [citation needed]. That's why you see so many slash-lgtm-slash-hold: because slash-lgtm, while CI is running, is catastrophic.

Thank you for noticing that that's what happened. I feel better now that I understand.

edsantiago added a commit to edsantiago/libpod that referenced this pull request Oct 18, 2023
Followup to containers#20394. For years (since BATS 1.5) we've been
seeing and ignoring nasty red warnings at the end of every
system test run. Thanks for fixing it, @giuseppe! But it
broke down in the '?' case when $expected_rc is empty:

   test/system/helpers.bash: line 345: [: -eq: unary operator expected

Simple fix.

Signed-off-by: Ed Santiago <[email protected]>
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Jan 17, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman exec leak ExecIds when command is not found
5 participants